package day_2023_7_to_10;

/**
 * @author haomin
 * @date 2023/08/17 23:53
 **/
public class Day_8_17 {
    public class Solution {
        // you need to treat n as an unsigned value
        int count = 32;
        public int hammingWeight(int n) {
            int res = 0;
            while(count-- != 0) {
                res += (n&1);
                n>>=1;
            }
            return res;
        }
    }
}